/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [Example_06_PriorityQueue.java]
 * Creation Date        [01-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_06_collections;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.PriorityQueue;

/**
 * 集合框架 java.util.PriorityQueue
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class Example_06_PriorityQueue {

	/**
	 * 测试方法
	 * 
	 * @param args
	 *            命令行参数
	 */
	public static void main(String[] args) {
		PriorityQueue<GregorianCalendar> queue = new PriorityQueue<GregorianCalendar>();
		queue.add(new GregorianCalendar(1906, Calendar.DECEMBER, 9));
		queue.add(new GregorianCalendar(1815, Calendar.DECEMBER, 10));
		queue.add(new GregorianCalendar(1903, Calendar.DECEMBER, 3));
		queue.add(new GregorianCalendar(1910, Calendar.JUNE, 22));
		System.out.println("迭代元素...");
		for (GregorianCalendar date : queue)
			System.out.println(date.get(Calendar.YEAR));
		System.out.println("移除元素...");
		while (!queue.isEmpty())
			System.out.println(queue.remove().get(Calendar.YEAR));
	}

}
